package com.ruoyi.purchase.domain;

import com.ruoyi.common.annotation.Excel;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.ArrayList;
import java.util.List;

/**
 * 订单详情对象 purchase_detail
 *
 * @author kevinness
 * @date 2025-01-03
 */
public class OrderDetail
{
    /** 订单明细编号 */
    private String orderDetailNo;

    /** 订单编号 */
    @Excel(name = "订单编号")
    private String orderNo;

    /** 货品编码 */
    @Excel(name = "货品批次")
    private String rawProductBatch;

    /** 货品名称 */
    @Excel(name = "货品名称")
    private String rawProductName;

    /** 预期到货时间 */
    private String expectedDeliveryTime;

    /** 物品种类 */
    private String goodsCategory;

    /** 货品件数 */
    @Excel(name = "货品数量")
    private Double quantity;

    /** 调拨数量 */
    private Double allocationQuantity;

    /** 货品单价 */
    @Excel(name = "货品单价")
    private Double unitPrice;

    /** 货品图片 */
    private String picture;

    public OrderDetail(){

    }

    public OrderDetail(String orderDetailNo, String orderNo, String rawProductBatch, String expectedDeliveryTime, Double quantity, Double unitPrice){
        this.orderDetailNo = orderDetailNo;
        this.orderNo = orderNo;
        this.rawProductBatch = rawProductBatch;
        this.expectedDeliveryTime = expectedDeliveryTime;
        this.quantity = quantity;
        this.unitPrice = unitPrice;
    }

    public String getOrderDetailNo() {
        return orderDetailNo;
    }

    public void setOrderDetailNo(String orderDetailNo) {
        this.orderDetailNo = orderDetailNo;
    }

    public void setOrderNo(String orderNo)
    {
        this.orderNo = orderNo;
    }

    public String getOrderNo()
    {
        return orderNo;
    }
    public String getRawProductName() {
        return rawProductName;
    }

    public void setRawProductName(String rawProductName) {
        this.rawProductName = rawProductName;
    }
    public void setRawProductBatch(String rawProductBatch)
    {
        this.rawProductBatch = rawProductBatch;
    }

    public String getExpectedDeliveryTime() {
        return expectedDeliveryTime;
    }

    public void setExpectedDeliveryTime(String expectedDeliveryTime) {
        this.expectedDeliveryTime = expectedDeliveryTime;
    }

    public String getRawProductBatch()
    {
        return rawProductBatch;
    }
    public String getGoodsCategory() {
        return goodsCategory;
    }

    public void setGoodsCategory(String goodsCategory) {
        this.goodsCategory = goodsCategory;
    }
    public void setQuantity(Double quantity)
    {
        this.quantity = quantity;
    }

    public Double getQuantity()
    {
        return quantity;
    }

    public Double getAllocationQuantity() {
        return allocationQuantity;
    }

    public void setAllocationQuantity(Double allocationQuantity) {
        this.allocationQuantity = allocationQuantity;
    }

    public void setUnitPrice(Double unitPrice)
    {
        this.unitPrice = unitPrice;
    }

    public Double getUnitPrice()
    {
        return unitPrice;
    }
    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    public static List<ChangeRecord> compareOrderDetail(OrderDetail oldDetail, OrderDetail newDetail) {
        List<ChangeRecord> changeRecords = new ArrayList<>();
        if(!oldDetail.getQuantity().equals(newDetail.getQuantity())) {
            String info = "货品 " + oldDetail.getRawProductName()
                    + " 的购买数量" + "由 "
                    + oldDetail.getQuantity()
                    + " 修改为 " + newDetail.getQuantity() + " ";
            changeRecords.add(new ChangeRecord("货品数量",info));
        }
        if(!oldDetail.getUnitPrice().equals(newDetail.getUnitPrice())) {
            String info = "货品 " + oldDetail.getRawProductName()
                    + " 的单价" + "由 "
                    + oldDetail.getUnitPrice()
                    + " 修改为 " + newDetail.getUnitPrice() + " ";
            changeRecords.add(new ChangeRecord("货品单价",info));
        }
        if(!oldDetail.getExpectedDeliveryTime().equals(newDetail.getExpectedDeliveryTime())) {
            String info = "货品 " + oldDetail.getRawProductName()
                    + " 的预期到货时间" + "由 "
                    + oldDetail.getExpectedDeliveryTime()
                    + " 修改为 " + newDetail.getExpectedDeliveryTime() + " ";
            changeRecords.add(new ChangeRecord("预期到货时间",info));
        }
        return changeRecords;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
                .append("orderDetailNo", getOrderDetailNo())
                .append("orderNo", getOrderNo())
                .append("rawProductBatch", getRawProductBatch())
                .append("rawProductName", getRawProductName())
                .append("expectedDeliveryTime", getExpectedDeliveryTime())
                .append("goodsCategory", getGoodsCategory())
                .append("quantity", getQuantity())
                .append("allocationQuantity", getAllocationQuantity())
                .append("unitPrice", getUnitPrice())
                .toString();
    }
}